<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <img src="" id="img" width="100" height="100" alt="">
  <script>
    var img = document.querySelector('#img')
    var imgUrl = 'https://avatars1.githubusercontent.com/u/40633121?s=460&v=4'
    var myImg = {
      setSrc (img, src) {
        img.src = src
      }
    }
    var proxyImg = {
      setSrc(img, src) {
        img.src = 'http://iph.href.lu/110x100';
        let image = new Image();
        image.onload = () => {
          img.src = src;
        }
        image.src = src;
      }
    }
    proxyImg.setSrc(img, imgUrl)
  </script>
</body>
</html>